<template>
  <div class="EntryFromEdit">
    <div class="form-title">
      <i class="el-icon-document"></i>
      <h4 class="form-title-text">保存</h4>
    </div>
      <div class="form-context">
        <el-form ref="form" :model="form.enroll" label-width="140px">
         <el-row style="width:900px;">
            <el-col :span="12">
              <el-form-item label="供应商代码">
                <el-input v-model="form.enroll.suppilercode"></el-input>
              </el-form-item>
            </el-col >
            <el-col :span="12">
              <el-form-item label="09条码">
                <el-input v-model="form.enroll.ljcode"></el-input>
              </el-form-item>
            </el-col >
         </el-row>
         <el-row style="width:900px;">
            <el-col :span="12">
              <el-form-item label="DC信息">
                <el-input v-model="form.enroll.dc"></el-input>
              </el-form-item>
            </el-col >
            <el-col :span="12">
              <el-form-item label="LOT信息(批次)">
                <el-input v-model="form.enroll.batch"></el-input>
              </el-form-item>
            </el-col >
         </el-row>
         <el-row style="width:900px;">
            <el-col :span="12">
             <el-form-item label="收货日期">
               <el-date-picker type="date" placeholder="选择日期" value-format="yyyy-MM-dd" v-model="form.enroll.recivetime" style="width:100%">
               </el-date-picker>
             </el-form-item>
            </el-col >
            <el-col :span="12">
              <el-form-item label="PO">
                <el-input v-model="form.enroll.po"></el-input>
              </el-form-item>
            </el-col >
         </el-row>
         <el-row style="width:900px;">
            <el-col :span="12">
              <el-form-item label="箱号">
                <el-input v-model="form.enroll.xh"></el-input>
              </el-form-item>
            </el-col >
            <el-col :span="12">
              <el-form-item label="物料版本">
                <el-input v-model="form.enroll.wlbb"></el-input>
              </el-form-item>
            </el-col >
         </el-row>
         <el-row style="width:900px;">
            <el-col :span="12">
              <el-form-item label="模穴号">
                <el-input v-model="form.enroll.mxh"></el-input>
              </el-form-item>
            </el-col >
            <el-col :span="12">
              <el-form-item label="外箱特殊标签">
                <el-input v-model="form.enroll.wxtsbq"></el-input>
              </el-form-item>
            </el-col >
         </el-row>
         <!--<el-row style="width:900px;">
           <el-form-item label="是否锁定">
            <el-col :span="12">
             <el-select v-model="form.enroll.state" placeholder="-请选择-" style="width:50%">
               <el-option label="是" value="1"></el-option>
               <el-option label="否" value="0"></el-option>
             </el-select>
            </el-col >
           </el-form-item>
         </el-row>-->
          <el-form-item>
            <el-button type="primary" @click="onSubmit">保存</el-button>
            <el-button @click="onCancel">取消</el-button>
          </el-form-item>
        </el-form>
      </div>
  </div>
</template>

<script>
    import Qs from 'qs'
    export default {
        name: 'OpenDayActivityEdit',
        data () {
            return {
              //form:{
                 //nroll: {
                     //suppilercode:'', /* 供应商代码*/
                     //ljcode:'', /* 09码*/
                    // dc:'', /* DC*/
                    // batch:'',  /* 批次*/
                    // recivetime:'',  /* 收货日期*/
                    // po:'',  /* po*/
                     //xh:'',  /* 箱号*/
                    // wlbb:'',   /* 物料版本*/
                    // mxh:'', /* 模穴号*/
                    // wxtsbq:""
                 //}
              //}
            }
        },
      created(){
        this.$store.commit("update",[{name:'日常工作',router:'/'},{name:'隔离条件',router:'/'}]);

      },
      methods:{
        onCancel(){
          this.$router.push({path:'OpenDayActivityForm',query:{activityId:this.$route.query.activityId,name:this.$route.query.name}});
        },
        onSubmit() {
           var url;
           if(this.form.enroll.id===''){
             this.form.enroll.id='0';
             url='/record/Save';
           }else{
             url='/record/Update';
           }
           if(this.form.enroll.state==undefined||this.form.enroll.state==""){
              this.form.enroll.state=0;
           }
           var param=Qs.stringify({record:JSON.stringify(this.form.enroll)});
            console.log(param);
            this.$axios.post(url,param,{headers:{'Content-Type':'application/x-www-form-urlencoded'}}).then(res=>{
               console.log(res.data);
               if(res.data){
                  this.$notify({
                     title: '成功',
                     message: '保存成功',
                     type: 'success'
                  });
                  this.$router.push('OpenDayActivityForm');
               }
            });

            return;
          this.$http.post('/Hd-NurseryShool/activity/updateOpebdayEntry',this.form.enroll).then(response => {
          if(response.status=='200'){
            this.$notify({
              title: '成功',
              message: '保存成功',
              type: 'success'
            });
              this.$router.push({path:'OpenDayEntryForm',query:{activityId:this.$route.query.activityId,name:this.$route.query.name}});
          }
          }, response => {
            this.$message('网络错误');
          });
        }
      },
      computed:{
          form:{
              get(){
                  return this.$store.state.enroll;
            },
            set(){

            }
          }
      }
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

  .EntryFromEdit{
    width:100%;
    heigth:100%;
    background-color:#fff;
    border-radius: 2px;
    border:1px solid #E1E6EB;
  }

  .form-title{
    width:100%;
    height:50px;
    background:#F5F6FA;
    display: flex;
    justify-content: flex-start;
    align-items: center;
  }
  .el-icon-document{
    color:#2196F3;
    margin-left:24px;
    font-size:12px;
  }
  .form-title-text{
    font-family: "Adobe 宋体 Std L";
    margin-left: 17px;
  }
  .form-context{
    margin:36px 50px;
    width:300px;
  }

</style>
